<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>config</title>
<script src="js/jquery-2.2.3.min.js"></script>
<script src="js/jquery-ui.min.js"></script>
<link type="text/css" href="css/jquery-ui.min.css" rel="stylesheet">
<link href="css/bootstrap.min.css" rel="stylesheet">
<script src="js/bootstrap.min.js"></script>
<script src="js/my.js"></script>
<link type="text/css" href="css/config.css" rel="stylesheet">

</head>
<body>
<div id="head">
	<div class="banner">
        <div class="nav">
       	    <ul class = "box">
				<li><a href="#"><h3>logo</h3></a></li>
            	<li><a href="#"><h3>首页</h3></a></li>
				<li><a href="base_config.html"><h3>系统设置</h3></a></li>
				<li><a href="#"><h3>Ajax</h3></a></li>
				<li><a href="login.html"><h3>切换帐号</h3></a></li>
				<li><a href="login.html"><h3>退出</h3></a></li>
            </ul>
        </div>
    </div>
</div>	
<br>
<div id="center">
	<h5>ajax获取后端返回数据：</h5>
	<input class="form-control" id="text" type="text" value="">
	<input type="button" value="获取" onclick="get();">
</div>	
<div class="bottom">
	<div class="footer">

	</div>
</div>
</body>
<script>
	function get()
	{
		var xmlhttp;
		if(window.XMLHttpRequest)
		{
			//code for IE7+,Firefox,Chrome,Opera,Safari
			xmlhttp=new XMLHttpRequest();
		}
		else
		{
			//code for IE6,IE5
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		xmlhttp.onreadystatechange=function()
		{
			if(xmlhttp.readyState==4 && xmlhttp.status==200)
			{
				//将接收到的字符串存入str
				var str = xmlhttp.responseText;
				if(str.length == 0)
				{
					return;
				}
				// 解决XML， 解析错误：语法错误
				try //Internet Explorer
				{
					xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
					xmlDoc.async = "false";
					xmlDoc.loadXML(text);
				} catch (e) {
					try //Firefox, Mozilla, Opera, etc.
					{
						parser = new DOMParser();
						xmlDoc = parser.parseFromString(str, "text/xml");
					} catch (e) { alert(e.message) }
				}

				var ret = xmlDoc.getElementsByTagName('p')[0].textContent;
				if(ret.length == 0)
				{
					
				}
				else
				{
					document.getElementById("text").value = ret;
				}
			}
		}
		xmlhttp.open("GET","cgi-bin/get.cgi?get",true);
		xmlhttp.send();
	}
</script>
</html>

